home *** CD-ROM | disk | FTP | other *** search
/ Linux Cubed Series 3: Developer Tools / Linux Cubed Series 3 - Developer Tools.iso / devel / make / icmake-6.000 / icmake-6 / icmake / comp / modulo.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-02-08  |  911 b   |  38 lines

  1. /*
  2.                             M O D U L O . C
  3. */
  4.  
  5. #include "iccomp.h"
  6.  
  7. ESTRUC_ *modulo (lval, rval)
  8.     ESTRUC_
  9.         *lval,
  10.         *rval;
  11. {
  12.     if (test_binop(op_mod, lval, rval))
  13.         return (lval);                      /* test for correct types */
  14.  
  15.     btoi(lval);                             /* convert pending booleans */
  16.     btoi(rval);
  17.  
  18.     if (conflict(lval, rval, op_mod))       /* test type conflict */
  19.         return(lval);
  20.  
  21.     if (test_type(rval, e_const))
  22.     {
  23.         if (!rval->evalue)                   /* no "E / 0" */
  24.         {
  25.             semantic("modulo 0: undefined");
  26.             clearbin(lval, rval);
  27.             return (lval);
  28.         }
  29.         if (test_type(lval, e_const))
  30.         {
  31.             lval->evalue %= rval->evalue;
  32.             return (lval);
  33.         }
  34.     }
  35.     defcode(lval, rval, op_mod);
  36.     return (lval);                          /* return new expression */
  37. }
  38.